home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.orig.lzh / relay / hdrdefs.c < prev    next >
C/C++ Source or Header  |  1989-06-27  |  4KB  |  111 lines

  1. /*
  2.  * Usenet header definitions (see ARPA Internet RFCs 1036 nee 850 & 822;
  3.  *    for a second opinion, see The Hideous Name by Pike & Weinberger).
  4.  *
  5.  * Headers are parsed and modified and copied in one pass.
  6.  * Nevertheless, the code is in pieces: hdrdefs.c, hdrcommon.c,
  7.  * hdrparse.c, hdrmunge.c.
  8.  */
  9.  
  10. #include <stdio.h>
  11. #include <sys/types.h>
  12. #ifdef REALSTDC
  13. #include <stdlib.h>
  14. #endif                /* REALSTDC */
  15. #include "news.h"
  16. #include "headers.h"
  17. #include "hdrint.h"        /* may define "const" */
  18.  
  19. #ifndef offsetof
  20. #define offsetof(type, mem) ((char *)&((type *)NULL)->mem - (char *)NULL)
  21. #endif
  22.  
  23. /* "mandatory" headers (also From:, Date:) */
  24. static const char msgnm[] =    "Message-ID:";    /* for rejection */
  25. static const char ngsnm[] =    "Newsgroups:";    /* filing, clone for Xref */
  26. static const char pathnm[] =    "Path:";    /* rejection, extend (damn) */
  27. static const char subjnm[] =    "Subject:";    /* for ctl. msgs. */
  28.  
  29. /* optional headers */
  30. static const char appnm[] =    "Approved:";    /* for mod. groups */
  31. static const char ctlnm[] =    "Control:";    /* ctl. msg. */
  32. static const char expnm[] =    "Expires:";    /* for history */
  33. static const char distrnm[] =    "Distribution:";    /* for transmission */
  34. static const char sendnm[] =    "Sender:";    /* for mod. groups */
  35. static const char xrefnm[] =    "Xref:";    /* to *replace* (damn!)*/
  36.  
  37. /* obsolete "useful" headers */
  38. static const char artnm[] =    "Article-I.D.:";    /* obs. Message-ID: */
  39.  
  40. /* obsolete useless headers: delete them all on contact */
  41. static const char datercvnm[] = "Date-Received:";
  42. static const char rcvnm[] =    "Received:";    /* obsolete Date-Received: */
  43. static const char postnm[] =    "Posted:";    /* obsolete Date: */
  44. static const char postversnm[] = "Posting-Version:";
  45. static const char rlyversnm[] = "Relay-Version:";
  46. static const char illobjnm[] = "Illegal-Object:";    /* zmailer bitching */
  47.  
  48. static const struct hdrdef msghdr = {
  49.     msgnm, STRLEN(msgnm), offsetof(struct headers, h_msgid) };
  50. static const struct hdrdef ngshdr = {
  51.     ngsnm, STRLEN(ngsnm), offsetof(struct headers, h_ngs) };
  52. const struct hdrdef pathhdr = {
  53.     pathnm, STRLEN(pathnm), offsetof(struct headers, h_path) };
  54. static const struct hdrdef subjhdr = {
  55.     subjnm, STRLEN(subjnm), offsetof(struct headers, h_subj) };
  56.  
  57. static const struct hdrdef apphdr = {
  58.     appnm, STRLEN(appnm), offsetof(struct headers, h_approved) };
  59. static const struct hdrdef ctlhdr = {
  60.     ctlnm, STRLEN(ctlnm), offsetof(struct headers, h_ctlcmd) };
  61. static const struct hdrdef exphdr = {
  62.     expnm, STRLEN(expnm), offsetof(struct headers, h_expiry) };
  63. static const struct hdrdef distrhdr = {
  64.     distrnm, STRLEN(distrnm), offsetof(struct headers, h_distr) };
  65. static const struct hdrdef sendhdr = {
  66.     sendnm, STRLEN(sendnm), offsetof(struct headers, h_sender) };
  67. const struct hdrdef xrefhdr = { xrefnm, STRLEN(xrefnm), -1 };
  68.  
  69. static const struct hdrdef arthdr = {
  70.     artnm, STRLEN(artnm), offsetof(struct headers, h_artid) };
  71.  
  72. static const struct hdrdef datrcvhdr = { datercvnm, STRLEN(datercvnm), -1 };
  73. static const struct hdrdef rcvhdr = { rcvnm, STRLEN(rcvnm), -1 };
  74. static const struct hdrdef psthdr = { postnm, STRLEN(postnm), -1 };
  75. static const struct hdrdef pstvrshdr = { postversnm, STRLEN(postversnm), -1 };
  76. static const struct hdrdef rlyvrshdr = { rlyversnm, STRLEN(rlyversnm), -1 };
  77. static const struct hdrdef illobjhdr = { illobjnm, STRLEN(illobjnm), -1 };
  78.  
  79. const hdrlist parsehdrs = {    /* these are parsed into a struct headers */
  80.     &msghdr,
  81.     &arthdr,        /* obsolete */
  82.     &ngshdr,
  83.     &pathhdr,        /* modified by hdrmunge.c (emithdr()) */
  84.     &subjhdr,
  85.     /* start optional headers */
  86.     &apphdr,
  87.     &ctlhdr,
  88.     &distrhdr,
  89.     &exphdr,
  90.     &sendhdr,
  91.     NULL
  92. };
  93. /*
  94.  * the following noxious headers are deleted on contact because neighbours
  95.  * still send them and they are big.  in an ideal world, they wouldn't be
  96.  * sent and thus we wouldn't need to delete them.
  97.  * It is tempting to delete Article-I.D.: too, but it may be too soon for that.
  98.  */
  99. const hdrlist hdrvilest = {
  100.     &xrefhdr,        /* regenerated by fileart() if needed */
  101.     &datrcvhdr,
  102.     &rcvhdr,
  103.     &psthdr,
  104.     &pstvrshdr,
  105.     &rlyvrshdr,
  106.     &illobjhdr,
  107.     NULL,
  108. };
  109.  
  110. boolean headdebug = NO;
  111.